<template>
  <div class="c-bg-sgray c-ph24">
    <div class="c-pt32 c-fs24" v-html="protocolInfo"></div>
  </div>
</template>

<script>
import { utilJs } from "@/utils/common.js";
export default {
  name: 'ProtocolInfo',
  components: {
  },
  props: [],
  beforeCreate() {

  },
  data() {
    return {
      theme: localStorage.getItem("colorName") || "mb5_default",
      protocolInfo: '',
      title: '隐私政策',
      companyName: window.localStorage.getItem("companyName"),
    }
  },
  created() {
  },
  mounted() {

  },
  computed: {

  },
  watch: {

  },
  methods: {
    getNewProtocol(protocolId) { // 新协议模块获取协议内容方法
      let companyId = utilJs.getCompanyIdByHerf();
      utilJs.getMethod(`${global.apiurl}protocols/getProtocol?protocolId=${protocolId}&companyId=${companyId}`, (res) => {
        this.protocolInfo = res.content;
        this.title = res.name;
        setDocumentTitle(this.title);
      });
    }
  },
  activated() {
    let fromType = this.$route.query.type;
    if (['user', 'privacy'].includes(fromType)) { // 用户协议、隐私协议走原本旧的接口，其余走新的协议接口
      this.title = fromType == 'user' ? '用户协议' : (fromType != 'vip' ? '隐私政策' : 'VIP服务协议');
      setDocumentTitle(this.title);
      let companyId = utilJs.getCompanyIdByHerf();
      utilJs.getMethod(`${global.apiurl}app/getProtocol?companyId=${companyId}`, (res) => {
        this.protocolInfo = fromType == 'vip' ? res.vipProtocol : fromType == 'user' ? res.useProtocol : res.privacyProtocol;
      });
    } else {
      this.getNewProtocol(this.$route.query.protocolId);
    }
  },
  deactivated() {

  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>
